//Team: Tuzzy Fester and the Testimonials
//Sara Thorup, Tom Lewis, & Becky Kluth
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


public class DeleteTest {
	LinkedList ll = null;

	@Before
	public void setUp() throws Exception {
		ll = new LinkedList(); //instantiate a new linked list for each test
	}

	//Try to remove a node from list when list is empty
	@Test
	public void testWithEmptyList() {
		ll.delete(1);
		Assert.assertEquals(null, ll.start);  //the start node should be null since the list is empty
	}

	//Try to delete the only node
	@Test 
	public void testDeleteOnlyNode() {
		ll.insert(1);
		ll.delete(1);
		Assert.assertEquals(null, ll.start);  //Since only node was removed, start node should now be null
	}
	
	//Try to delete the first node
	@Test
	public void testDeleteFirst() {
		ll.insert(1);
		ll.insert(2);
		ll.insert(3);
		ll.delete(1);
		Assert.assertEquals(2, ll.start.getData()); //
	}
	
	//Try to delete the last node
	@Test
	public void testDeleteLast() {
		ll.insert(1);
		ll.insert(2);
		ll.insert(3);
		ll.delete(3);
		Assert.assertEquals(null, ll.start.getNext().getNext());  
	}
	
	//Try to delete the middle node
	@Test 
	public void testDeleteMiddle() {
		ll.insert(1);
		ll.insert(2);
		ll.insert(3);
		ll.delete(2);
		Assert.assertEquals(3, ll.start.getNext().getData());
	}
	
	//Try to delete a node that doesn't exist
	@Test
	public void testNotInList() {
		ll.insert(1);
		ll.insert(2);
		ll.insert(3);
		ll.delete(4);
		
		//Would expect no change to the list (not sure if this is the best way to test this)
		Assert.assertEquals(1, ll.start.getData());
		Assert.assertEquals(2, ll.start.getNext().getData());
		Assert.assertEquals(3, ll.start.getNext().getNext().getData());
		
	}


}
